/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cms.dataaccess.hibernate;

import cms.dataaccess.ConferenceItemOrderDAO;
import cms.exceptions.HibernateAccessLayerException;
import dto.Confitemorder;
import java.util.List;

/**
 *
 * @author TauPo
 */
public class ConferenceItemOrderDAOImpl extends AbstractDAO implements ConferenceItemOrderDAO {

    @Override
    public List<Confitemorder> findConfitemorderByConferenceName(String conferenceName) throws HibernateAccessLayerException {
      
        try {  
         return (List<Confitemorder>)(this.findByCustomizeQuery(Confitemorder.class, "conferenceName='"+conferenceName+"'"));
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public List<Confitemorder> findConfitemorderByItemName(String itemName) throws HibernateAccessLayerException {
        try {  
         return (List<Confitemorder>)(this.findByCustomizeQuery(Confitemorder.class, "itemName='"+itemName+"'"));
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public List<Confitemorder> findConfitemorderByOrderUser(String orderUser) throws HibernateAccessLayerException {
         try {  
         return (List<Confitemorder>)(this.findByCustomizeQuery(Confitemorder.class, "ItemOrderBy='"+orderUser+"'"));
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public Confitemorder findConfitemorder(String conferenceName, String itemName, String orderUser) throws HibernateAccessLayerException {
         try {  
         return ((List<Confitemorder>)(this.findByCustomizeQuery(Confitemorder.class, "conferenceName='"+conferenceName+ 
                                           "' and itemName='"+itemName+"' and ItemOrderBy='"+orderUser+"'"))).get(0);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }

    @Override
    public List<Confitemorder> findByCustomizeQuery(String queryString) throws HibernateAccessLayerException {
        return  (List<Confitemorder>)(this.findByCustomizeQuery(Confitemorder.class,queryString));
    }

    @Override
    public List<Confitemorder> findAllConfitemorder() throws HibernateAccessLayerException {
        try {
            List result = super.findAll(Confitemorder.class);
            return (result);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
        }
        
    }
    
    @Override
    public void insertConfitemorder(Confitemorder confitemorder) throws HibernateAccessLayerException {
        try {
            super.saveOrUpdate(confitemorder);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }
    
    @Override
    public void updateConfitemorder(Confitemorder confitemorder) throws HibernateAccessLayerException {
       try {
            super.saveOrUpdate(confitemorder);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
     }

    @Override
    public void deleteConfitemorder(Confitemorder confitemorder) throws HibernateAccessLayerException {
        try {
            super.delete(confitemorder);
        } catch (Throwable t) {
            throw new HibernateAccessLayerException(t.toString());
            
        }
    }
}
